/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.icad.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Gabriel Bran gbran.u@gmail.com
 */
@Entity
@Table(name = "iglesia")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Iglesia.findAll", query = "SELECT i FROM Iglesia i"),
    @NamedQuery(name = "Iglesia.findById", query = "SELECT i FROM Iglesia i WHERE i.id = :id"),
    @NamedQuery(name = "Iglesia.findByNombre", query = "SELECT i FROM Iglesia i WHERE i.nombre = :nombre"),
    @NamedQuery(name = "Iglesia.findByPastor", query = "SELECT i FROM Iglesia i WHERE i.pastor = :pastor"),
    @NamedQuery(name = "Iglesia.findByFechaFundacion", query = "SELECT i FROM Iglesia i WHERE i.fechaFundacion = :fechaFundacion")})
public class Iglesia implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "nombre")
    private String nombre;
    @Size(max = 100)
    @Column(name = "pastor")
    private String pastor;
    @Column(name = "fecha_fundacion")
    @Temporal(TemporalType.DATE)
    private Date fechaFundacion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "iglesia1")
    private List<TransaccionContable> transaccionContableList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "iglesia")
    private List<Miembro> miembroList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "iglesia1")
    private List<TipoDocumento> tipoDocumentoList;
    @OneToMany(mappedBy = "iglesiaPadre")
    private List<Iglesia> iglesiaList;
    @JoinColumn(name = "iglesia_padre", referencedColumnName = "id")
    @ManyToOne
    private Iglesia iglesiaPadre;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "iglesia1")
    private List<CatalogoContable> catalogoContableList;

    public Iglesia() {
    }

    public Iglesia(Integer id) {
        this.id = id;
    }

    public Iglesia(Integer id, String nombre) {
        this.id = id;
        this.nombre = nombre;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getPastor() {
        return pastor;
    }

    public void setPastor(String pastor) {
        this.pastor = pastor;
    }

    public Date getFechaFundacion() {
        return fechaFundacion;
    }

    public void setFechaFundacion(Date fechaFundacion) {
        this.fechaFundacion = fechaFundacion;
    }

    @XmlTransient
    public List<TransaccionContable> getTransaccionContableList() {
        return transaccionContableList;
    }

    public void setTransaccionContableList(List<TransaccionContable> transaccionContableList) {
        this.transaccionContableList = transaccionContableList;
    }

    @XmlTransient
    public List<Miembro> getMiembroList() {
        return miembroList;
    }

    public void setMiembroList(List<Miembro> miembroList) {
        this.miembroList = miembroList;
    }

    @XmlTransient
    public List<TipoDocumento> getTipoDocumentoList() {
        return tipoDocumentoList;
    }

    public void setTipoDocumentoList(List<TipoDocumento> tipoDocumentoList) {
        this.tipoDocumentoList = tipoDocumentoList;
    }

    @XmlTransient
    public List<Iglesia> getIglesiaList() {
        return iglesiaList;
    }

    public void setIglesiaList(List<Iglesia> iglesiaList) {
        this.iglesiaList = iglesiaList;
    }

    public Iglesia getIglesiaPadre() {
        return iglesiaPadre;
    }

    public void setIglesiaPadre(Iglesia iglesiaPadre) {
        this.iglesiaPadre = iglesiaPadre;
    }

    @XmlTransient
    public List<CatalogoContable> getCatalogoContableList() {
        return catalogoContableList;
    }

    public void setCatalogoContableList(List<CatalogoContable> catalogoContableList) {
        this.catalogoContableList = catalogoContableList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Iglesia)) {
            return false;
        }
        Iglesia other = (Iglesia) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.icad.entity.Iglesia[ id=" + id + " ]";
    }
    
}
